package com.doctor.windflower_doctor.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.doctor.windflower_doctor.R;
import com.doctor.windflower_doctor.actionBeen.UserControlBeen;

public class DialogueMoveAdapter extends BaseAdapter {
	private List<UserControlBeen> list;
	private Context context;
	private int position1 = 9999;

	public DialogueMoveAdapter(List<UserControlBeen> list, Context context) {
		this.list = list;
		this.context = context;

	}

	public void setPosition(int position) {
		position1=position;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.move_item, null);
			holder.textView = (TextView) convertView
					.findViewById(R.id.groupname_textView);
			holder.imageView_yes = (ImageView) convertView
					.findViewById(R.id.imageView_yes);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		if (position1 == position) {
			
			holder.imageView_yes.setVisibility(View.VISIBLE);
		}else{
			holder.imageView_yes.setVisibility(View.INVISIBLE);
		}
		holder.textView.setText(list.get(position).getGroupName());
		return convertView;
	}

	class ViewHolder {
		TextView textView;
		ImageView imageView_yes;
	}
}
